!run_consumer.

+!run_consumer : true <- 
	!setup_tools;
	!get_day;
	!do_request.

+!get_day : xmlManager(XMLManager) & wsProxy(ProxyID)<-
	Msg = "<tns:GetDayRequest xmlns:tns='http://example.com/timeprovider.wsdl'><tns:day>DIA</tns:day></tns:GetDayRequest>";
	requestOp("GetDay", Msg, Res, ResID)[artifact_id(ProxyID)];
	cartago.invoke_obj(Res,getBody,MsgBody);
	cartago.invoke_obj(XMLManager,buildElementFromString(MsgBody),Elem);
	cartago.invoke_obj(XMLManager,getElementValue("TradeDay","day", Elem), Value);
	.print("Day: ",Value).

+!do_request : xmlManager(XMLManager) & wsProxy(ProxyID)<-
	Msg = "<tns:GetTimeRequest xmlns:tns='http://example.com/timeprovider.wsdl'><tns:time>HORA</tns:time></tns:GetTimeRequest>";
	requestOp("GetTime", Msg, Res, ResID)[artifact_id(ProxyID)];
	cartago.invoke_obj(Res,getBody,MsgBody);
	cartago.invoke_obj(XMLManager,buildElementFromString(MsgBody),Elem);
	cartago.invoke_obj(XMLManager,getElementValue("TradeTime","time", Elem), Value);
	.print("Time: ",Value);
	.wait(2000);
	!!do_request.
  	    
+!setup_tools : true <-
.print("Creating CWSServerArtifact");
	makeArtifact("proxy1", "cartagows.WSInterface", ["data/timeprovider.wsdl"], ProxyID);
	+wsProxy(ProxyID);   
	.print("WSInterface built.");
	cartago.new_obj("cartagows.util.XMLibJason",[],XMLManager);
  	+xmlManager(XMLManager);
  	.print("XMLManager built").